//2009/08/29 02:07:24
#include <iostream>
#include <string>
#include <vector>
#include <map>
#include <queue>
#include <math.h>
#include <sstream>
#include <algorithm>

using namespace std;

class MaximumScoredNumber
{
public:
    int getNumber(int lowerBound, int upperBound)
    {
		int mmax = -1;
		int ret = -1;
		for(int i=upperBound; i>=lowerBound; i--)
		{
			if(mmax < score(i) || mmax == -1)
			{
				mmax = score(i);
				ret = i;
			}
		}
		return ret;
    }
    int score(int n)
    {
        int ret = 0;
        for (int i=0; i*i<=n/2; i++)
            if (issquare(n - i*i))
                ret++;
        return ret;
    }
    bool issquare(int n)
    {
        int a = (int) sqrt(n);
        if (a * a == n) return true;
        return false;
    }
};
